import React, { useEffect, useState, createRef } from 'react'


export default function useMouse () {

    const [position, setPosition] = useState({
        x: 0,
        y: 0
    })

    useEffect(() => {



        const fn = (e) => {

            setPosition({ x: e.pageX, y: e.pageY })


        }
        window.addEventListener('mousemove', fn)
        return () => {
            window.removeEventListener('mousemove', fn)
        }
    }, [])



    return position
}